<?php
namespace Home\Controller;
use Home\Model\SetcardModel;
use Think\Controller;


class NetlogController extends BaseController {
    public function netlog(){
        $url=$_SESSION['cardinfo'][self::$cardtype_wz]['cardip'] . C('LUCI_WIFISCAN_URL')
            . 'UserInfo/'. 'nil%20nil%20nil%20nil%20nil%20';
        $retdata = http_post_json($url, null);
        $js=(json_decode($retdata, true));
        $terminal=D('terminal');
        for($iloop=0; $iloop<count($js[0]);$iloop++){
            $terminaldata=$terminal->where(array('term_id'=>$js[0][$iloop]['term_id']))->limit(1)->select();
            $js[0][$iloop]['term_id']=$terminaldata[0]['term_cn_name'];
        }
        $this->assign('userinfo', $js[0]);
        $this->display();
    }

    public function UserBehavi(){
        if(IS_POST){
            $url=$_SESSION['cardinfo'][self::$cardtype_wz]['cardip'] . C('LUCI_WIFISCAN_URL')
                . 'UserBehavi/'. 'nil%20'. I('post.mac') .'%20nil%20nil%20nil%20';

            $retdata = http_post_json($url, null);
            $js=(json_decode($retdata, true));

            $app=D('app');
            $keywords=D('keywords');
            for($iloop=0; $iloop < count($js[0]); $iloop++){
                $appdata=$app->where(array('app_id'=>$js[0][$iloop]['appid']))->limit(1)->select();
                $js[0][$iloop]['appid']=$appdata[0]['ch_name'];

                $keywordsdata=$keywords->where(array('typeid'=>$js[0][$iloop]['keytype']))->limit(1)->select();
                $js[0][$iloop]['keytype']=$keywordsdata[0]['desc'];
                if($js[0][$iloop]['urlencode']>0){
                    $js[0][$iloop]['keyword']=urldecode($js[0][$iloop]['keyword']);
                }
            }
            $this->ajaxReturn(array('status'=>true, 'data'=>$js[0]), 'JSON');
        }
    }

    public function UserSurUrl(){
        if(IS_POST){
            $mac= mb_convert_case (I('post.mac'),MB_CASE_LOWER, "UTF-8");

            $url=$_SESSION['cardinfo'][self::$cardtype_wz]['cardip'] . C('LUCI_ADMIN_URL')
                . 'behavioranalysis/cli_acc_url/'.$mac;
            //var_dump($url);
            $retdata = http_post_json($url, null);
            $js=(json_decode($retdata, true));

            $this->ajaxReturn(array('status'=>true,   'data'=>$js[0]), 'JSON');
        }
    }
}
